package com.wc.算法提高课.E第五章_数学知识.欧拉函数.最大公约数;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/4 19:42
 * @description https://www.acwing.com/problem/content/description/222/
 */

public class Main {
    /**
     * 思路：
     * 欧拉函数 见 算法提高客.数学知识.可见的点<p>
     * gcd(x, y) = p, 假设 p 是素数<p>
     * gcd(x / p, y / p) = 1<p>
     * 让 x' = x / p, y' = y / p, x', y'互质<p>
     * 原来的题意也就可以等价于求1 <= x', y' <= N / p中的 x', y'互质的数, <p>
     * 这样就可以用到欧拉函数phi[i]<p>
     * 求数对, 假设 x' < y', 那么x', y'可以互换,对于x', y'相等,那一定是等于1, 就说明是x, y两个质数, 那就多加了一份相等的, 所以需要=1<p>
     * s[n] = /sum_1_n phi[i]<p>
     * res = /sum_1_n/p (2 * s[y'] - 1)
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    private static final int N = (int) 1e7 + 10;
    static int[] primes = new int[N / 10], phi = new int[N];
    static boolean[] st = new boolean[N];
    static long[] s = new long[N];
    static int n, cnt = 0;


    public static void main(String[] args) {
        ola();
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) s[i] = s[i - 1] + phi[i];
        long res = 0;
        for (int i = 0; primes[i] <= n; i++) {
            int p = primes[i];
            res += 2 * s[n / p] - 1;
        }
        out.println(res);
        out.flush();
    }

    static void ola() {
        st[0] = st[1] = true;
        phi[1] = 1;
        for (int i = 2; i < N; i++) {
            if (!st[i]) {
                phi[i] = i - 1;
                primes[cnt++] = i;
            }
            for (int j = 0; i <= (N - 1) / primes[j]; j++) {
                st[i * primes[j]] = true;
                if (i % primes[j] == 0) {
                    phi[i * primes[j]] = phi[i] * primes[j];
                    break;
                }
                phi[i * primes[j]] = phi[i] * (primes[j] - 1);
            }
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
